<template>
  <div>
    <div v-if="layered" class="box" :style="{ height: height, width: width }">
      <div class="innerbox top">{{ title }}</div>
      <div class="innerbox">
        <slot>{{ content }}</slot>
      </div>
    </div>
    <div v-else class="innerbox box" :style="{ height: height, width: width }">
      <slot>{{ content }}</slot>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    title: {
      type: String,
      default: ''
    },
    width: {
      type: String || Number,
      default: '300px'
    },
    height: {
      type: String || Number,
      default: ''
    },
    content: {
      type: String || Number,
      default: ''
    }
  },
  data() {
    return {
      layered: false
    }
  },
  watch: {
    title: {
      immediate: true,
      handler(val) {
        if (val) this.layered = true
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.innerbox {
  padding: 20px;
}
.top {
  background-color: #f2f6fc;
  color: #606266;
  padding: 15px 20px;
  background: #f2f6fc;
  font-weight: 700;
}
.box {
  border: 1px solid #dcdfe6;
}
</style>
